//
//  NotifyDetailViewController.swift
//  LongTermInsurance
//
//  Created by zolobdz on 2019/1/10.
//  Copyright © 2019年 HeChao. All rights reserved.
//

import UIKit
import ObjectMapper

class NotifyDetailViewController: BaseViewController {

    @IBOutlet weak var titleLabel: UILabel!
    
    @IBOutlet weak var dateLabel: UILabel!
    
    @IBOutlet weak var readCountLabel: UILabel!
    
    @IBOutlet weak var contentView: UITextView!
    
    var notifyID = 0.0
//    var model = NotifyDetailModel?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "通知"
        getNotifyData()
    }

    func getNotifyData() {
//        guard let info = MyselfSingleton.shared.userInfo else{
//            return
//        }
        CDUtility.showHud()
        let json = ["NoticeNo": notifyID].convertToJsonString()
        let paramString = "<json>"+json+"</json>"
        NetworkingHandle.fetchNetworkData(method: "getNoticeDetail", paramString: paramString, success: {[weak self] (dict) in
            CDUtility.hidHud()
            if let imgsString = dict.convertToJsonString().lowercased() as? String {
                if let model = Mapper<NotifyDetailModel>().map(JSONString: imgsString.lowercased()) {
                    self?.contentView.text = model.content
                    self?.titleLabel.text = model.title
                    self?.dateLabel.text = model.date
                    self?.readCountLabel.text = "阅读数：\(model.readCount)"
                    print("")
                }
            }
            if let code = dict["ResultCode"] as? Int,code == 1 {
                if let msgString = dict["ResultMessage"] as? String {
                    CDUtility.showMSG(message: msgString)
                }
            }
        }) {
            CDUtility.hidHud()
            print("")
        }
    }
    
}
